<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../lib/vue.js"></script>
</head>

<body>
    <div id="root">
        <h2>当前的值是：<span v-text="n"></span></h2>
        <h2>放大十倍: <span v-big="n"></span> </h2>
        <button @click="n++">n+1</button>
        <hr>
        <input type="text" v-fbind:value="n">
    </div>
</body>
<script>
    Vue.config.productionTip = false;

    new Vue({
        el: "#root",
        data: {
            n: 1
        },
        directives: {
            big(element, binding) {
                element.innerText = binding.value * 10;
            },
            fbind: {
                //指令与原色成功绑定时
                bind(element, binding) {
                    element.value = binding.value;
                },
                //指令所在元素被插入页面时
                inserted(element, binding) {
                    element.focus();
                },
                //指令所在页面的模板被重新解析时
                update(element, binding) {
                    element.value = binding.value;
                }
            }
        }
    })
</script>

</html>